<template>
    <div>
        <navigation-bar>
            <div class="searchContent">
                <el-input v-model="unitName" placeholder="请输入名称" size="mini" style="width: 150px; margin-right: 10px"></el-input>
                <custom-button type="search" style="margin-right: 10px" @searchClick="searchClick"></custom-button>
                <custom-button type="reset" style="margin-right: 10px" @resetClick="resetClick"></custom-button>
            </div>
        </navigation-bar>

        <div style="margin-top: 10px">
            <table-index
                :dataSource="dataSource"
                :tableColumns="tableColumns"
                :btnList="[]"
                :pageSize="pageSize"
                :pageCount="pageCount"
                :pageNo="pageNo"
                @pageChange="pageChange"
                @handleCurrentChange="handleCurrentChange"
                :height="height"
            ></table-index>
        </div>
    </div>
</template>

<script>
import customDialog from '@/components/customComponents/customDialog'
import customButton from '@/components/customComponents/customForm/customButton'
import formIndex from '@/components/customComponents/customForm/formIndex'
import tableIndex from '@/components/customComponents/customeTable/iviewTable/singleViewTable'
import navigationBar from '@/components/customComponents/managementCenter/navigationBar'
import {AjaxCommon} from '@/libs/apiCommon'
import {PopupCommon} from '@/libs/popupCommon'
export default {
    props: ['height'],
    components: {
        navigationBar,
        customButton,
        tableIndex,
        customDialog,
        formIndex
    },
    data() {
        return {
            unitName: null,
            // table 相关参数  begin
            dataSource: [],
            tableColumns: [
                {
                    type: 'index',
                    width: 60,
                    align: 'center'
                },
                {
                    key: 'USER_NAME',
                    title: '登录用户名'
                },
                {
                    key: 'URealName',
                    title: '用户真实姓名'
                },
                {
                    key: 'user_tel',
                    title: '联系方式'
                },
                {
                    key: 'UIdCard',
                    title: '用户身份证'
                },
                {
                    key: 'UAddress',
                    title: '用户地址'
                }
            ],
            pageSize: 20,
            pageCount: 100,
            pageNo: 1
            // table 相关参数  end
        }
    },
    created() {},
    methods: {
        customClick(isTrue) {
            this.useOrg(isTrue)
        },
        searchClick() {
            this.pageNo = 1
            this.initPage()
        },
        resetClick() {
            this.unitName = null
            this.searchClick()
        },

        // 分页点击事件
        pageChange(p) {
            this.pageNo = p
            this.initPage()
        },
        handleCurrentChange(d) {
            this.$emit('handleCurrentChange', d)
        },
        // 初始化事件
        initPage() {
            // 组织机构类型（0：个人 1：企业）
            let self = this
            const params = `?PageSize=${this.pageSize}&PageIndex=${this.pageNo}&orgType=0&OrgName=${this.unitName}`
            AjaxCommon(`/api/OrgSysManage/GetOrgPageDatas${params}`, 'get', null).then((res) => {
                console.log(res, 'res...........')
                if (res?.data?.Code == 200) {
                    const data = res?.data.Message
                    console.log(data?.rows, 'data?.rows...')
                    self.dataSource = data?.rows
                    self.pageCount = parseInt(data?.total)
                } else {
                    PopupCommon.notify('error', res?.data?.msg)
                }
            })
        }
    },
    mounted() {
        this.$nextTick(() => {
            this.initPage()
        })
    }
}
</script>

<style></style>
